package com.sure0000.akka.ch1;

import java.util.HashMap;
import java.util.Map;

import akka.actor.AbstractActor;
import akka.event.Logging;
import akka.event.LoggingAdapter;
import akka.japi.pf.ReceiveBuilder;

public class AkkademyDb extends AbstractActor {
    protected final LoggingAdapter log = Logging.getLogger(context().system(), this);
    public final Map<String, Object> map = new HashMap<>();

    private AkkademyDb() {
        receive(
            ReceiveBuilder.match(SetRequest.class, message -> {
                log.info("received set request: {}", message);
                map.put(message.getKey(), message.getValue());
            }).matchAny(o -> {
                    log.info("received unknow message: {}", o);
            }).build()
        );
    }
}
